﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TVideo.Model;

namespace TVideo.Util
{
    public class PlaySourceUtil
    {
        private static List<PlaySource> _sourceList = new List<PlaySource>();

        static PlaySourceUtil()
        {
            Init();
        }

        public static List<PlaySource> GetAll()
        {
            return _sourceList;
        }

        public static PlaySource GetDefault()
        {
            return _sourceList[0];
        }

        public static string GetDefaultName()
        {
            var source = GetDefault();
            return source.Name;
        }

        public static PlaySource? GetByName(string name)
        {
            return _sourceList.FirstOrDefault(m => m.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
        }

        private static void Init()
        {
            _sourceList.Add(new PlaySource("Line1", "线路一", "https://jx.aidouer.net"));
            _sourceList.Add(new PlaySource("Line2", "线路二", "http://freeget.org/jx.php"));
            _sourceList.Add(new PlaySource("Line3", "线路三", "http://okjx.cc"));
            _sourceList.Add(new PlaySource("Line4", "线路四", "https://www.1717yun.com/jx/ty.php"));
        }
    }
}
